home *** CD-ROM | disk | FTP | other *** search
/ PC Elektro 3 / PC-Elektro-3-cd1.bin / KBan 2.0 / KBANSRC.LZH / SRC / PROG / NETLIST / SEGPOINT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-23  |  498 b   |  22 lines

  1. // the implementation of segpoint
  2. // Copyright (C) 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
  3.  
  4. #include "../common/base.h"
  5. #include "hesse.h"
  6. #include "seg.h"
  7. #include "xydbl.h"
  8.  
  9. #include "segpoint.h"
  10.  
  11. double GetDistanceFromOrigin(const SEGMENT& seg)
  12. {
  13.   XY_DBL o(0, 0);
  14.   double distance = minimum(get_distance(o, seg.p1()), get_distance(o, seg.p2()));
  15.   HESSE hesse(seg);
  16.   if(hesse.on_segment()) {
  17.     distance = minimum(distance, hesse.c());
  18.   }
  19.  
  20.   return distance;
  21. }
  22.